package com.wuliupai.delivery.wuliupaidelivery.net;

import android.content.Context;

import com.wuliupai.delivery.wuliupaidelivery.App;
import com.wuliupai.delivery.wuliupaidelivery.utils.LogUtils;

/**
 * Descriptions：处理网络请求结果的接口
 * <p>
 * Author：ChenME
 * Date：11/10/2016
 * Email：ibelieve1210@163.com
 */
public abstract class NetResultOperate {

    public static final String CUSTOM_STATE_NET_ERROR = "custom_01";//自定义状态——网络异常
    public static final String STATE_SUCCESS = "0";//成功
    public static final String STATE_LOGIN_EXPIRED = "1";//登陆超时
    //    private static final String STATE_INPUT_ERR = "2";//您输入的信息有误
//    private static final String="3";//数据库操作错误
    public static final String STATE_DATA_EMPTY = "4";//没有数据
    public static final String STATE_DATA_END = "5";//已到最后
    public static final String STATE_OPERATION_FREQUENTLY = "6";//操作频繁，请稍作休息operation frequently
    //    private static final String ="7";//验证码错误或已过期
    public static final String STATE_LOGIN_AT_OTHER_DEVICE = "8";//您的账号已在其他设备登陆，请重新登陆
    public static final String STATE_LOGIN_EXPIRED2 = "9";//您太久没有登陆过，请重新登陆
    //    private static final String ="10";//您的秘钥错误
//    private static final String ="11";//用户尚未注册
    public static final String STATE_PASSWORD_ERR = "12";//密码错误
    public static final String WITHDRAWAL_FAILURE_CURRENT_CARD_CANNOT_CHANGED = "1110";


    /**
     * 数据返回成功
     *
     * @param content 网络返回的内容
     */
    public abstract void onSuccess(String content);

    /**
     * 数据错误
     *
     * @param errorCode 错误码
     * @param errorMsg  错误信息
     */
    public void onErr(String errorCode, String errorMsg, Context mContext) {
//        new AlertDialog.Builder(mContext)
//                .setMessage(errorMsg)
//                .setTitle(mContext.getString(R.string.string_netLoading_errorTitle))
//                .setNegativeButton(mContext.getString(R.string.string_commonConfirmBtn), new DialogInterface.OnClickListener() {
//                    @Override
//                    public void onClick(DialogInterface dialog, int which) {
//                        dialog.dismiss();
//                    }
//                })
//                .create()
//                .show();
        LogUtils.log("网络错误：errorCode = "+errorCode+"； errorMsg = " +errorMsg+";");
        App.toast(errorMsg);
    }

    /**
     * 数据为空
     *
     * @param content 网络返回的内容
     */
    public abstract void onDataEmpty(String content);

    /**
     * 数据已经到最后
     *
     * @param content 网络返回的内容
     */
    public abstract void onDataEnd(String content);
}